package com.shenmazong.servertalkstudent.controller;

import com.shenmazong.servertalkstudent.service.TbStudentService;
import com.shenmazong.utils.ResponseResult;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 田不平
 * @project demo-easytalk
 * @date 2020/9/16 10:50 AM
 * http://www.shenmazong.com
 */

@RestController
@Slf4j
@CrossOrigin
@Api(tags = "学生管理微服务")
public class StudentController {


    @Autowired
    private TbStudentService studentService;



    /**
     * @Description:修改密码
     * @Author: 王大勇
     * @Date: 2020/9/17 9:00
     * @param userId:
     * @param oldPass:
     * @param newPass:
     * TODO setUserPass 修改密码
     * @return: com.shenmazong.utils.ResponseResult
     **/
    @PostMapping("/setUserPass")
    @ApiOperation(value = "修改学生密码", notes = "修改学生密码")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "学生id", dataType = "Integer", required=true),
            @ApiImplicitParam(name="oldPass", value = "老密码", dataType = "String", required=true),
            @ApiImplicitParam(name="newPass", value = "新密码", dataType = "String", required=true)
    })
    public ResponseResult setUserPass(@RequestParam("userId") Integer userId,
                                      @RequestParam("oldPass") String oldPass,
                                      @RequestParam("newPass") String newPass) {
        return studentService.setUserPass(userId, oldPass, newPass);
    }

    /**
     * @Description:获取所有自己的课时
     * @Author: 王大勇
     * @Date: 2020/9/17 9:00
     * @param userId:
     * @param pageCurrent:
     * @param pageSize:
     * TODO getClassByPage 获取所有自己的课时（倒序）
     * @return: com.shenmazong.utils.ResponseResult
     **/
    @PostMapping(value = "/getClassByPage")
    @ApiOperation(value = "获取所有自己的课时", notes = "获取所有自己的课时")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "学生id", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageCurrent", value = "起始页", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageSize", value = "每页几条", dataType = "Integer", required=true),
    })
    public ResponseResult getClassByPage(
            @RequestParam("userId") Integer userId,
            @RequestParam("pageCurrent") Integer pageCurrent,
            @RequestParam("pageSize") Integer pageSize
    ) {
        return studentService.getClassByPage(userId, pageCurrent, pageSize);
    }

    /**
     * @Description:获取已经上完的课时
     * @Author: 王大勇
     * @Date: 2020/9/17 9:01
     * @param userId:
     * @param pageCurrent:
     * @param pageSize:
     * TODO getFinishClassByPage 获取已经上完的课时（时间降序）
     * @return: com.shenmazong.utils.ResponseResult
     **/
    @PostMapping(value = "/getFinishClassByPage")
    @ApiOperation(value = "获取已经上完的课时", notes = "获取已经上完的课时")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "学生id", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageCurrent", value = "起始页", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageSize", value = "每页几条", dataType = "Integer", required=true),
    })
    public ResponseResult getFinishClassByPage(@RequestParam("userId") Integer userId,
                                         @RequestParam("pageCurrent") Integer pageCurrent,
                                         @RequestParam("pageSize") Integer pageSize

    ) {
        return studentService.getFinishClassByPage(userId, pageCurrent, pageSize);
    }


    /**
     * @Description:获取未来要上的课时
     * @Author: 王大勇
     * @Date: 2020/9/17 9:01
     * @param userId:
     * @param pageCurrent:
     * @param pageSize:
     * TODO getWillClassByPage 获取未来要上的课时（时间升序）
     * @return: com.shenmazong.utils.ResponseResult
     **/
    @PostMapping(value = "/getWillClassByPage")
    @ApiOperation(value = "获取未来要上的课时", notes = "获取未来要上的课时")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "学生id", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageCurrent", value = "起始页", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageSize", value = "每页几条", dataType = "Integer", required=true),
    })
    public ResponseResult getWillClassByPage(@RequestParam("userId") Integer userId,
                                               @RequestParam("pageCurrent") Integer pageCurrent,
                                               @RequestParam("pageSize") Integer pageSize

    ) {
        return studentService.getWillClassByPage(userId, pageCurrent, pageSize);
    }


    /**
     * @Description:
     * @Author: 王大勇
     * @Date: 2020/9/17 9:16
     * @param userId:
     * @param pageCurrent:
     * @param pageSize:
     * TODO getPayFeeByPage 获取交费总费用
     * @return: com.shenmazong.utils.ResponseResult
     **/
    @PostMapping(value = "/getPayFeeByPage")
    @ApiOperation(value = "获取交费总费用", notes = "获取交费总费用")
    @ApiOperationSupport(order = 1)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="userId", value = "学生id", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageCurrent", value = "起始页", dataType = "Integer", required=true),
            @ApiImplicitParam(name="pageSize", value = "每页几条", dataType = "Integer", required=true),
    })
    public ResponseResult getPayFeeByPage(@RequestParam("userId") Integer userId,
                                             @RequestParam("pageCurrent") Integer pageCurrent,
                                             @RequestParam("pageSize") Integer pageSize

    ) {
        return studentService.getPayFeeByPage(userId, pageCurrent, pageSize);
    }
}
